<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      section {
        width: 1190px;
        margin: 50px auto;
        background-color: aquamarine;
        display: flex;
        justify-content: space-between;
        flex-wrap: wrap;
      }
      article {
        width: 372px;
        height: 174px;
        border: 1px solid #000;
        margin-bottom: 20px;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <section>
        <pro-item
          v-for="(item, index) in proList"
          :key="index"
          :item="item"
        ></pro-item>
      </section>
    </div>

    <script src="./lib/vue3.js"></script>
    <script>
      const ProItem = {
        props: ["item"],
        template: `
          <article>
            <h3>{{ item.title }}</h3>
            <img :src="item.imgUrl" />
          </article>
        `,
      };

      Vue.createApp({
        data() {
          return {
            proList: [],
          };
        },
        components: {
          ProItem,
        },
        mounted() {
          fetch("http://10.36.188.127:3000")
            .then((response) => response.json())
            .then((res) => {
              // console.log(res);
              this.proList = res.list;
            });
        },
      }).mount("#app");
    </script>
  </body>
</html>
